package com.church.action;

import java.util.Map;

import com.church.services.QandaServices;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class AddAnswer extends ChurchActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = 31L;
	private QandaServices qandaServices;
	private String answer;
	private long id;
	private boolean response;
	public QandaServices getQandaServices() {
		return qandaServices;
	}
	public void setQandaServices(QandaServices qandaServices) {
		this.qandaServices = qandaServices;
	}
	public String getAnswer() {
		return answer;
	}
	public void setAnswer(String answer) {
		this.answer = answer;
	}
	public long getId() {
		return id;
	}
	public void setId(long id) {
		this.id = id;
	}
	
	public boolean getResponse() {
		return response;
	}
	public void setResponse(boolean response) {
		this.response = response;
	}
	public String execute() {
		String userName="teacher";
 
		try {
			userName = this.getUserInfo().getUserName();
			//answer = new String(answer.getBytes("ISO-8859-1"),"UTF-8");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response=qandaServices.answer(id, userName, answer).equals("success");
		return SUCCESS;
	}
}
